how to save data to memory javascript